home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
comm
/
tlx_sq15.zip
/
DNLOAD.SLT
< prev
next >
Wrap
Text File
|
1991-02-02
|
26KB
|
775 lines
//-----------------------------------------------------------
// DNLOAD.SL? Automatic download from BBS systems.
str dll_file [] = "DOWNLOAD"; // Download log file.
//-----------------------------------------------------------
// The file <BBS>.DL must be placed in TELIX's program (main)
// directory. <BBS> consists of the first 8 (max.) alphabetic
// characters of the BBS name.
// The following parameters must be defined in this file:
// Filename to download.
// Filename to download
// etc.
// Example:
// GAME1.ZIP
// GAME2.ZIP
// GRAPHICS.ZIP
// You may specify as many files as you want. However, the
// script attempts to download only 10 files. The script does
// not attempt to download files that are already in the download
// directory. Thus you may run the script repeatedly to download
// more files (if you have enough file time) without having to
// modify the specification file manually.
// These files are downloaded to the directory defined for
// this purpose in TELIX. You may NOT specify directory
// (path) in the download specifications.
// If you have suggestions for generalizing this script
// without making it too complicated, please upload your
// new version to this BBS, or suggest improvements to me
// via old-fashioned mail to:
// Inge Vabekk
// Hamangskogen 108
// N-1300 SANDVIKA
// NORWAY
//-----------------------------------------------------------
// Hint: Define a softkey to trigger this file (define in NAME.DAT)
str dls_file [14] // Download specifications
,NextConf [14] // Next conference
,PrevConf [14] // Previous conference
,myprot [2] // "My" protocol
,hisprot [2] // The BBS's protocol
,shortname [8] // Short name of BBS.
,input [80] // Input line.
,runstr [80] // Run string for DSZ.
,f0 [14] // Filename for download.
,command [10] // Command prompt.
,temp [4] // Temporary for short strings.
,password [14] // Password for file download.
// For the Global storage:
,global []="GLOBAL" // Global script.
,bbstype []="BTYPE" // BBS type.
,short []="SHORT" // Short BBS name.
,Cprot []="CPROT" // Current protocol.
,Hprot []="HPROT" // "His" protocol.
,version []="PCBVER" // PCB version
,conf []="CONF" // Current conference
,prompt []="PROMPT" // Current command prompt.
,maxdn []="MAXDN" // Max. files for download.
,dsz []="DSZ" // DSZ parameters.
,filist []="FILIST" // Name of the BBS file list
,fpass []="FPASS" // Password for downloading.
;
// Other constants and variables.
int tol = 300 // timeout limit 30 sec.
,tmark, stat
,mbbs, pcb, rbbs, opus, fido, crcs // Possible BBS types
,PCBver // PCBoard version.
,infile // Input file pointer
,infilemenu // TRUE if in file menu
,success // Count of succesful downloads.
,fail = 0 // Number of failures.
,MAX // Max # files to download
,MORE // More files to download
,switched // TRUE (1) if conferences switched.
,protocol // Must be INT.
,usedsz // TRUE if using DSZ.
;
//-----------------------------------------------------------
// DNload script starts here.
//-----------------------------------------------------------
main()
{
int c, i, k; // Temporary storage.
int error;
entry(); // Updates colors & status bar.
// Check if online.
//-----------------------------------------------------------
if (!carrier())
{ status_wind ("YOU CAN ONLY DOWNLOAD IF YOU'RE ONLINE!",20);
return (-1);
}
// Find BBS type (Set one logical variable).
read (bbstype,input); // Get BBS type,
mbbs = pcb = rbbs = opus = fido = crcs = 0;
if (input == "MBBS") mbbs = 1;
else if (input == "PCB" )
{ pcb = 1;
read (version,temp);
PCBver = stoi (temp); // PCB version.
}
else if (input == "RBBS") rbbs = 1;
else if (input == "OPUS") opus = 1;
else if (input == "FIDO") fido = 1;
else if (input == "CRCS") crcs = 1;
else
{ wrongBBS(); // Doesn't match script!
return (-1);
}
read (prompt,command); // Get command prompt.
read (cprot,myprot); // Protocol.
protocol = toupper(subchr(myprot,0));
read (hprot,hisprot); // His protocol.
if (pcb) NextConf = "Main Board"; // Join Main conference.
read (conf,PrevConf); // Get current conference.
switched = 0;
read (short,shortname); // Get the short name and build
dls_file = shortname; // name of download spec. file.
strcat (dls_file,".DL"); // Add extension.
infile = filesize(dls_file); // Check if download file exists.
if (infile < 0) // If not,
{ run ("HAVEIT$",shortname,0); // run program to build it.
infile = filesize(dls_file); // Check result.
}
if (infile > 0)
infile = fopen (dls_file,"r"); // Open file for READ.
if (infile <= 0) goto done; // No file???
read (maxdn,temp);
MAX = MORE = stoi (temp); // More files to check:
success = 0; // No files so far.
if (read (dsz,runstr) > 0 // Are we using DSZ?
&& protocol == 'Z')
{ strcat (runstr," rz -m"); // Add parameters.
usedsz = 1;
}
infilemenu = 0; // NOT in file menu yet.
while ((error=fgets (input,80,infile)) > 0 // Download files.
&& MORE && (success < MAX)
&& carrier())
{ if (strlen(input) < 3)
break; // Line too short to make sense.
i = 0;
do
{ for (k=0; (c=subchr(input,i))>='!'; ++i)
{ c = toupper(c);
if (k==0)
if (c=='#' || c=='+' || c=='-' || c=='&')
continue;
setchr (f0,k,c); // ANY char. > space)
++k;
}
++i;
if (!c) break; // Break out at end of line.
} while (k < 2); // One char. is not enough!
setchr (f0,k,0); // End of string.
for(i=0; (c=subchr(input,i))<=' '; ++i)
; // Find first character.
if (c=='#' || c =='+' || c=='-') // Change conference?
{ substr (input,++i,14,NextConf); // Copy conference name.
getfiles(); // Get files in hold first.
setconf(c); // Set conference.
}
else if (c=='&') // Password?
{ substr (input,++i,14,password); // Copy password.
write (fpass,password); // Update password.
}
else
if (k > 1) DL(); // Download this file....
}
getfiles(); // Get files in hold.
fclose (infile); // Close the command file.
done:
fdelete (dls_file);
if (!carrier()) return (-1);
return(0);
}
//-----------------------------------------------------------
// Get files in hold.
//-----------------------------------------------------------
getfiles()
{
int i;
if (PCBver > 144) return; // Older versions only.
if (!infilemenu) return; // Only if we're in the
infilemenu = 0; // file menu.
if (pcb)
{ cputs ("^M"); // Send CR to terminate.
if (success) // Start transfer now?
{ waitfor ("(A)bort?",10);
cputs ("^M");